package Simulation;

import fxana.FxRawDataSet;

public abstract class Simulator {

	public Simulator(){
		return;
	}
	
	abstract protected void ParameterOptimize(FxRawDataSet dataset,EvaluatorParaFlag  pflag);
	abstract protected void OneTest(FxRawDataSet dataset,EvaluatorParaFlag  pflag);
	abstract protected void OutParameter(FxRawDataSet dataset,EvaluatorParaFlag  pflag);
	public void DoSimulator(String[] args){
		EvaluatorParaFlag  pflag=new EvaluatorParaFlag ();
		pflag.SetFlagByCmdline(args);
		if(!pflag.IsParameterOK()|| (!pflag.IsBFlagSet()&&!pflag.IsOFlagSet()&&!pflag.IsEFlagSet())){
			return;
		} 
		
		FxRawDataSet dataset=new FxRawDataSet();
		if(dataset.LoadRawData(pflag.GetFilename())==false){
			System.err.println("Load datafile"+pflag.GetFilename()+"failed!");
			return;
		}
		
		//if(pflag.IsNFlagSet()&& pflag.GetNFlagIterator().hasNext()){
			//dataset.SetCompositeDataBuffer(pflag.GetNFlagIterator().next());
		//}
		
		if(pflag.IsBFlagSet()){
			this.ParameterOptimize(dataset,pflag);
		}else if(pflag.IsOFlagSet()){
			this.OutParameter(dataset,pflag);
		}else if(pflag.IsEFlagSet()){
			this.OneTest(dataset,pflag);
		}
		return;
	}
}
